package sql;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;

import bo.Users;
import control.database.*;

public class UpdateUsers {
	public String update(Users users) throws SQLException
		{
		String message = "";
		ResultSet rs = null;
		int userid = users.getUserid();
		String sql="";
		DataBase db=new DataBase();
		sql="update users set lastLoginDate='"+new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+"',state="+users.getState()+"where userid="+userid;
		db.executeUpdate(sql);
		db.closeStmt();
        db.closeConn();
        sql = "select * from users where userid=" + userid;
        rs = db.executeQuery(sql);
        for(message = "insert failse"; rs.next(); message = "insert successfull");
        rs.close();
        db.closeStmt();
        db.closeConn();
        return message;
		
	}
	

}
